<template>
	<view class="">
		<u--form errorType="toast" :model="formData" ref="myForm" :rules="rules" labelWidth="80">
			<u-form-item label="操作类型:" prop="dataType" borderBottom>
				<u-radio-group v-model="formData.dataType">
					<u-radio shape="circle" label="充值" :name="1" activeColor="#e54d42"></u-radio>
					<u-radio shape="circle" label="扣除" :name="2" activeColor="#e54d42"></u-radio>
				</u-radio-group>
			</u-form-item>
			<u-form-item label="操作金额:" prop="amount" borderBottom>
				<u-input v-model="formData.amount" border="none" type="number" placeholder="请输入操作金额" />
			</u-form-item>
			<u-form-item label="备注信息:" prop="remark">
				<u-input v-model="formData.remark" placeholder="请输入备注信息" border="none" />
			</u-form-item>
		</u--form>
		<view class="pl-30 pr-30 mt-40">
			<u-button color="#e54d42" text="确认结算" @click="submit" size="large"/>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data(){
			return {
				formData: {
					staffId: null,
					dataType: 1,
					amount: null,
					remark: '',
				},
				rules: {
					amount: [{
						required: true,
						message: '请输入操作金额',
						trigger: ['blur', 'change']
					}],
					remark: [{
						required: true,
						message: '请输入备注信息',
						trigger: ['blur', 'change']
					}],
				}
			}
		},
		onLoad(opt) {
			this.formData.staffId = opt.id
		},
		onReady() {
			this.$refs.myForm.setRules(this.rules)
		},
		methods: {
			submit() {
				const that = this
				this.$refs.myForm.validate().then(res => {
					that.$reqJsonPost('StoreStaffStockDoCreate', that.formData).then(res=>{
						that.$refs.uToast.show({
							message:res.msg,
							complete(){
								uni.$emit('upDetail', {staffid: that.formData.staffId})
								uni.navigateBack()
							}
						})
					})
				})
			}
		}
	}
</script>

<style lang='scss' scoped>
</style>